package meiRiYiTi;

/**
 * @Author: wzp
 * @CreateTime: 2024-09-29  08:59
 * @Description: TODO
 * @Version: 1.0
 */
public class day_2073 {

    public int timeRequiredToBuy(int[] tickets, int k) {
        int sum=tickets[k];
        int result=0;
        for (int i = 0; i < k; i++) {
            if(tickets[i]<=sum){
                result+=tickets[i];
            }else{
                result+=sum;
            }
        }
        for (int i = k+1; i < tickets.length; i++) {
            if(tickets[i]<=sum-1){
                result+=tickets[i];
            }else{
                result+=sum-1;
            }
        }
        return result+sum;
    }
}
